home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt86oct.arc
/
ALLOC.ARC
/
ALLOC4.DEF
< prev
next >
Wrap
Text File
|
1985-07-12
|
2KB
|
43 lines
DEFINITION MODULE Alloc4;
(* A safe storage allocator using the first-fit method and capabilities.
Copyright 1986 by Jonathan Amsterdam. All Rights Reserved. *)
FROM SYSTEM IMPORT WORD;
EXPORT QUALIFIED capability, blockSize, getWord, setWord, allocate, free,
getFreeList, resize, writeMap;
TYPE capability; (* offset to a pointer, and generation count*)
PROCEDURE blockSize(c:capability):CARDINAL;
(* Size of block *)
PROCEDURE getWord(c:capability; n:CARDINAL):WORD;
(* Returns n'th word of block. Block indexed from 0 to blockSize-1;
dies if n > blockSize-1. *)
PROCEDURE setWord(c:capability; n:CARDINAL; w:WORD);
(* sets n'th word of block to w; dies if n > blockSize-1. *)
PROCEDURE allocate(nWords:CARDINAL):capability;
(* allocates a block of nWords words (possibly slightly more, in some cases) *)
PROCEDURE free(VAR freeBlock:capability);
(* frees block pointed to by freeBlock if it points into the heap, and sets
freeBlock to NIL. *)
PROCEDURE resize(c:capability; nWords:CARDINAL);
(* attempts to change size of block referenced by h *)
PROCEDURE writeMap;
(* Writes, in order of address, the free and allocated blocks and their
sizes. For debugging only; should be removed in "production" versions
of the allocator. *)
PROCEDURE getFreeList():capability; (* really a blockPtr *)
(* Returns a pointer to the free list. For debugging only. This should
be removed in "production" versions of the allocator. *)
END Alloc4.
o the free list